var util = require('../../utils/util')
var wxRequest = require('../../utils/wxRequest')
const app = getApp();
Page({
  data: {
    //判断小程序的API，回调，参数，组件等是否在当前版本可用。
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    hiddenmodalput: true
  },
  onLoad: function (options) {
    wx.clearStorage();

    //冻结状态
    if (options.status == "freeze") {
      this.setData({
        hiddenmodalput: false
      });
    }


  },
  bindGetUserInfo: function (e) {
    console.log(e);
    if (e.detail.userInfo) {
      //用户按了允许授权按钮
      var that = this;
      let token = wx.getStorageSync('token')
      console.log("auth:", token);
      if (!token) {
        app.getUserInfo()
      } else {
        //授权成功后，跳转进入小程序首页
        wx.switchTab({
          url: '/pages/index/index'
        })
      }

    } else {
      //用户按了拒绝按钮
      wx.showModal({
        title: '警告',
        content: '请您授权登录使用小程序',
        showCancel: false,
        confirmText: '返回授权',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击了“返回授权”')
          }
        }
      })

      
    }
  },

})